/*
 * Copyright(c) 2018-? the original author[Wien(luweien@aliyun.com)] or authors.
 *
 */
package org.doll.it.sequence;

import org.doll.it.sequence.impl.TwitterSnowFlake;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

@Configuration
@ConditionalOnProperty(name = "doll.sequence.enabled", havingValue = "true", matchIfMissing = true)
@Import({ DollSequencePorperties.class })
public class DollSequenceAutoConfig {

	@Autowired
	private DollSequencePorperties dsProperties;

	@Bean
	@ConditionalOnMissingBean(TwitterSnowFlake.class)
	public TwitterSnowFlake defaultSnowFlake() {
		return new TwitterSnowFlake(dsProperties.getInstanceId());
	}

}
